package com.du.integration.server.handle;

import com.du.integration.server.handle.filter.MqttTopicFilter;
import com.du.integration.server.handle.filter.MqttTopicFilterFactory;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.mqttv5.common.MqttMessage;

/**
 * @Desc :
 * @Author: shuangdu
 * @date : 2024/1/9
 */
@Slf4j
public class ChatMsgHandle implements MqttMsgHandle {

    private MqttTopicFilter topicFilter;

    @Override
    public boolean filter(String topic) {
        return topicFilter.filter(topic);
    }

    @Override
    public void handle(String topic, MqttMessage mqttMessage) {
        log.info("topic: {}, msg: {}", topic, mqttMessage);


    }

    @Override
    public void register(String topic) {
        this.topicFilter = MqttTopicFilterFactory.toFilter(topic);
        MqttMsgHandleFactory.registerHandle(topic, this);
    }
}
